<template>
  <main>
    <div class="borard">
      <img src="../assets/login-logo.png" object-fit="scale-down" />
      <div class="right">
        <div class="title">Hello!</div>
        <div class="describe">欢迎来到GameTool!</div>
        <el-input v-model="inputName" placeholder="请输入用户名" clearable>
          <template #prefix>
            <el-icon size="18px"><user /></el-icon>
          </template>
        </el-input>
        <div class="checkTips">用户名不能为空</div>
        <form>
          <el-input
            v-model="inputPassword"
            placeholder="请输入密码"
            type="password"
            clearable
            show-password
          >
            <template #prefix>
              <el-icon size="18px"><lock /></el-icon>
            </template>
          </el-input>
        </form>

        <div class="checkTips">密码不能少于6位</div>

        <el-input v-model="inputCode" placeholder="请输入验证码" clearable @blur="checkCode">
          <template #prefix>
            <el-icon size="18px"><message /></el-icon>
          </template>
          <template #append>
            <CodeCheck contentWidth="150" contentHeight="48" @changeCode="onChangeCode"></CodeCheck>
          </template>
        </el-input>
        <div :class="showCodeTips ? 'checkTips' : 'hideCheckTips'">验证码错误</div>

        <el-button type="primary" @click="login">登录</el-button>
      </div>
    </div>
  </main>
</template>
<script setup lang="ts">
import { User } from '@element-plus/icons-vue'
import { ref } from 'vue'
import CodeCheck from '../components/CodeCheck.vue'
import { useRouter } from 'vue-router'
const inputName = ref('')
const inputPassword = ref('')
const inputCode = ref('')
const showCodeTips = ref(false)
const router = useRouter()
let code = ''
const checkCode = () => {
  console.log(inputCode.value === code)
  showCodeTips.value = inputCode.value !== code
}
const onChangeCode = (v:string) => {
  console.log(v)
  inputCode.value = ''
  code = v
}
const login = () => {
  router.push('main')
}
</script>
<style scoped>
main {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #7da7f5;
  @media screen and (max-width: 600px) {
    img {
      display: none;
    }
  }
  .borard {
    background-color: white;
    min-width: 350px;
    height: 550px;
    border-radius: 20px;
    display: flex;
    justify-content: center;
    img {
      width: 50%;
      object-fit: scale-down;
    }
    .right {
      min-width: 400px;
      margin-left: 30px;
      margin-right: 30px;
      display: flex;
      flex-direction: column;
      /* align-items: center; */
      justify-content: center;
      .title {
        font-size: 54px;
      }
      .describe {
        margin: 20px 0 15px 0;
        font-size: 26px;
      }
      .el-input {
        height: 48px;
      }

      .checkTips {
        visibility: show;
        font-size: 12px;
        color: #fd4e4e;
        margin-bottom: 10px;
        -webkit-user-select: none; /* Safari */
        -moz-user-select: none; /* Firefox */
        -ms-user-select: none; /* IE10+/Edge */
        user-select: none; /* 标准语法 */
      }
      .hideCheckTips {
        visibility: hidden;
      }
      .el-button {
        height: 50px;
        width: 100%;
      }
      :deep(.el-input-group__append) {
        padding: 0;
      }
      .unselectable-text {
        -webkit-user-select: none; /* Safari */
        -moz-user-select: none; /* Firefox */
        -ms-user-select: none; /* IE10+/Edge */
        user-select: none; /* 标准语法 */
      }
    }
  }
}
</style>
